package com.mac.hosp_pre.admin.controller;

import com.mac.hosp_pre.admin.model.resp.ScheduleRespDto;
import com.mac.hosp_pre.reply.R;
import com.mac.hosp_pre.admin.service.ScheduleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Tag(name = "排班管理接口")
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @Operation(summary ="查询排班规则数据")
    @Parameters({
            @Parameter(name = "page", description = "当前页码", required = true),
            @Parameter(name = "limit", description = "每页记录数", required = true),
            @Parameter(name = "hospCode", description = "医院编号", required = true),
            @Parameter(name = "deptCode", description = "科室编号", required = true)
    })
    @GetMapping("getScheduleRule/{page}/{limit}/{hospCode}/{deptCode}")
    public R getScheduleRule(@PathVariable long page,
                             @PathVariable long limit,
                             @PathVariable String hospCode,
                             @PathVariable String deptCode) {
        Map<String,Object> map = scheduleService.getRuleSchedule(page,limit,hospCode,deptCode);
        return R.success(map);
    }

    @Operation(summary = "查询排班详细信息", description = "根据医院编号、科室编号、日期查询排班详细信息")
    @Parameters({
            @Parameter(name = "hospCode", description = "医院编号", required = true),
            @Parameter(name = "deptCode", description = "科室编号", required = true),
            @Parameter(name = "workDate", description = "排班日期", required = true)
    })
    @GetMapping("getScheduleDetail/{hospCode}/{deptCode}/{workDate}")
    public R getScheduleDetail( @PathVariable String hospCode,
                                     @PathVariable String deptCode,
                                     @PathVariable String workDate) {
        List<ScheduleRespDto> detailSchedule = scheduleService.getDetailSchedule(hospCode, deptCode, workDate);
        return R.success(detailSchedule);
    }
}
